package com.lianxi

import scala.collection.mutable.ArrayBuffer

/**
  * Created by adengdeng on 2017/8/7 
  */
object Lx8 {

  def main(args: Array[String]): Unit = {
    val a = ArrayBuffer(0, 1, -2, 3, -4, 5)
    //集合中负数的下标，反转，移除第一个负数的下标（也就是最后一个下标）
    val indexs = (for(i<- 0 until a.length if a(i) < 0) yield i).reverse.dropRight(1)

    for (i <- indexs) a.remove(i)

    println(a.mkString(" "))
  }
}
